import QtQuick 2.7
import QtQuick.Controls 2.5

import "./widgets" as Widgets
import "./layouts" as Layouts

/////////////////////////////// 资料输入页面 ////

Rectangle {
    id: root

    signal back()
    signal backWithCode(string code)
    signal requestShowSacnBarcode()

    ///////////////////////////////////////// UI ////
    Layouts.TopLayout {
        id: toolBar
        z: 100
        width: parent.width
        height: root.height * 0.1
        title: qsTr("")

        onClickedBack: root.back()
    }

    Item {
        width: parent.width
        height: parent.height - toolBar.height
        y: toolBar.height

        Column {
            width: parent.width
            anchors.centerIn: parent
            spacing: 12

            Widgets.LogoLayout {
                width: parent.width
                height: root.height * 0.15
            }

            Label {
                width: parent.width
                height: root.height * 0.15
                horizontalAlignment: Label.AlignHCenter
                verticalAlignment: Label.AlignVCenter

                text: qsTr("輸入/確認樣品提供者資料")
                font.pixelSize: height * 0.3
            }

            Widgets.BorderTextField {
                id: txtText
                anchors.horizontalCenter: parent.horizontalCenter
                width: parent.width * 0.6
                height: root.height * 0.08
            }

            Item {
                width: parent.width
                height: root.height * 0.12
                Widgets.FlatButton {
                    id: btnScan
                    anchors.horizontalCenter: parent.horizontalCenter
                    width: parent.width * 0.15
                    height: root.height * 0.05
                    backgroundColor: "#333"
                    radius: 0
                    text: qsTr("掃碼")

                    onClicked: {
                        requestShowSacnBarcode()
                    }
                }
            }

            Widgets.FlatButton {
                id: btnConfirm
                enabled: txtText.text.length > 0
                anchors.horizontalCenter: parent.horizontalCenter
                width: parent.width * 0.3
                height: root.height * 0.08
                text: qsTr("確定")

                onClicked: backWithCode(txtText.text)
            }

        }
    }

}
